package com.petecat.interchan;

import java.util.Date;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import com.petecat.interchan.base.project.entity.EsSoftPercent;
import com.petecat.interchan.base.project.entity.ServerInfoDTO;
import com.petecat.interchan.base.project.service.IProjectService;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = BaseApplication.class)
public class EsQueryServerPercent {

	@Autowired
	private IProjectService projectService;
	
	private ServerInfoDTO serverInfoDTO;
	
	private String userId;
	
	@Before
	public void getProjectServer() {
		serverInfoDTO = new ServerInfoDTO();
		serverInfoDTO.setProjectId("948098720305954816");
		serverInfoDTO.setNewTime(new Date().getTime()/1000);
		serverInfoDTO.setTime(1516674423L);
		serverInfoDTO.setServerMac("7c:67:a2:7d:0b:99");
		serverInfoDTO.setToken("953168716228956160");
		serverInfoDTO.setType("D");
		userId = "1";
	}
	
	/**
	 * 通过Token和Mac查询服务器使用率%圖表
	 */
	@Test
	public void queryServerPercentInfo() {
		List<EsSoftPercent> queryServerPercent = projectService.queryServerPercent(serverInfoDTO,userId);
		queryServerPercent.parallelStream().forEach(per->System.out.println(per.toString()));
	}
	

}
